//
//  ChooseCityLayout.m
//  UIA段项目 墨家天气
//
//  Created by dllo on 15/8/23.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "ChooseCityLayout.h"

@implementation ChooseCityLayout
-(instancetype)init
{
    
    
    self = [super init];
    if (self) {
        self.dicArr = [NSMutableArray array];
        
    }
    return self;
}
- (void)prepareLayout
{
    [super prepareLayout];
    
    NSInteger itemNum = [self.collectionView numberOfItemsInSection:0];
    for (int i = 0; i < itemNum; i ++) {
        
        NSIndexPath *index = [NSIndexPath  indexPathForRow:i inSection:0];
        
        UICollectionViewLayoutAttributes *att = [UICollectionViewLayoutAttributes layoutAttributesForCellWithIndexPath:index];
        
        
        
        att.frame = CGRectMake(i  % 4 * (self.collectionView.frame.size.width - 50  * OffWidth) / 4 + 40 * OffWidth  , i / 4 * (self.collectionView.frame.size.height - 400 * OffHeight)/ 4 + 300  * OffHeight, (self.collectionView.frame.size.width - 100 * OffWidth) / 4, 50 * OffHeight);
    
        [self.dicArr addObject:att];
    }
    
    
    
    
    
    
    
    
}
- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect
{
    NSMutableArray *arr = [NSMutableArray array];
    for (UICollectionViewLayoutAttributes *att in self.dicArr) {
        
        [arr addObject:att];
        
    }
    
    return arr;
    
    
    
}
- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return [self.dicArr objectAtIndex:indexPath.item];
}
@end
